package com.nervenets.shopping.controller.order.params;

import com.nervenets.general.enumeration.Platform;
import com.nervenets.general.exception.LogicException;
import com.nervenets.general.web.params.FormParams;
import com.nervenets.shopping.enumeration.PayType;
import com.nervenets.shopping.enumeration.WealthType;
import com.nervenets.shopping.hibernate.domain.order.RechargeOrder;
import com.nervenets.shopping.service.RechargeOrderService;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class RechargeOrderFormParams extends FormParams<RechargeOrder, RechargeOrderService> {
    @ApiModelProperty(value = "支付内容描述", required = true)
    @NotBlank
    private String detail;
    @ApiModelProperty(value = "支付金额", required = true)
    @Positive
    private int money;
    @ApiModelProperty(value = "实际到账", required = true)
    @Positive
    private int actually;
    @ApiModelProperty(value = "资产类型", required = true)
    @NotNull
    private WealthType wealthType;
    @ApiModelProperty(value = "支付方式", required = true)
    @NotNull
    private PayType payType;
    @ApiModelProperty(value = "来源平台", required = true)
    @NotNull
    private Platform platform;

    @Override
    public RechargeOrder validateAndBuild(RechargeOrderService service, HttpServletRequest request, HttpServletResponse response) {
        if (getFormId() > 0) throw new LogicException("充值订单不支持编辑操作");
        return super.validateAndBuild(service, request, response);
    }
}
